<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="__PUBLIC__/style/css/public.css">
<link rel="stylesheet" href="__PUBLIC__/style/cssn/pintuer.css">
<link rel="stylesheet" href="__PUBLIC__/style/cssn/admin.css">
<script src="__PUBLIC__/style/jsn/jquery.js"></script>
<script src="__PUBLIC__/style/jsn/pintuer.js"></script>
</head>
<body>
<form method="get" action="" id="">
    <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 内容列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    <div class="padding border-bottom">
      <ul class="search" style="padding-left:10px;">
        
        <li>搜索：</li>
        <!-- <li>
          推荐
          <select name="s_isvouch" class="input" onchange="changesearch()"  style="width:60px; line-height:17px;display:inline-block">
            <option value="">选择</option>
            <option value="1">是</option>
            <option value="0">否</option>
          </select>
          
        </li> -->
        <li>
          <input type="text" placeholder="请输入搜索产品名称" name="search" class="input sear" style="width:250px; line-height:17px;display:inline-block" value="{$search}" />
          <button class="button border-main icon-search"> 搜索</button></li>
      </ul>
    </div>
</form>
<form method="post" action="{:U('Admin/Carousel/del')}" id="listform">
    <table class="table table-hover text-center">
        <tr>
            <th width="100" style="text-align:left; padding-left:20px;">ID</th>
            <th>轮播图</th>
            <th>序号</th>
            <th width="310">操作</th>
        </tr>
        <foreach name="data" item="da">
        <tr>
            <td style="text-align:left; padding-left:20px;"><input type="checkbox" name="id[]" value="{$da['id']}" />{$da['id']}</td>
            <td><img style="width:100px;" src="__PUBLIC__{$da['pic']}"></td>
            <td>{$da['sort']}</td>
            <td><div class="button-group"> <a class="button border-main" href="{:U('Admin/Carousel/edit',array('id'=>$da['id']))}"><span class="icon-edit"></span> 修改</a> <a class="button border-red" href="javascript:void(0)" type="{$da['id']}" onclick="del({$da['id']})"><span class="icon-trash-o"></span> 删除</a> </div></td>
        </tr>
        </foreach>
        <tr>
            <td style="text-align:left; padding:19px 0;padding-left:20px;"><input type="checkbox" id="checkall"/>全选 </td>
            <td colspan="7" style="text-align:left;padding-left:20px;"><a href="javascript:void(0)" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()"> 批量删除</a> </td>
        </tr>
      
        <!-- <tr>
            <td colspan="8"><div class="pagelist"> <a href="">上一页</a> <span class="current">1</span><a href="">2</a><a href="">3</a><a href="">下一页</a><a href="">尾页</a> </div></td>
        </tr> -->
    </table>
    </div>
</form>
<!--页码-->
    <div class="productPage">
        {$pagestr}
    </div>
<script type="text/javascript">

//单个删除
function del(id){

	if(confirm("您确定要删除吗?")){
		$.ajax({
            type:'post',
            url :'{:U('Admin/Carousel/delete')}',
            data:{id:id},
            success : function(da){
                if(da==1){
                    alert('删除成功');
                    window.location.href="{:U('Admin/Carousel/index')}";
                }else if(da==2){
                    alert('删除失败');
                    window.location.href="{:U('Admin/Carousel/index')}";
                }
            }
        })
	}
}

//全选
$("#checkall").click(function(){ 
    $("input[name='id[]']").each(function(){
	    if (this.checked) {
		    this.checked = false;
	    }
	    else {
		    this.checked = true;
	    }
    });
})

//批量删除
function DelSelect(){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认要删除选中的内容吗？");
		if (t==false) return false;
		
        $.ajax({
            type:'post',
            url :'{:U('Admin/Carousel/del')}',
            data:$("#listform").submit(),
            success : function(dd){
                // if(dd==1){
                //     alert('删除成功');
                //     window.location.href="{:U('Admin/Carousel/index')}";
                // }else if(dd==2){
                //     alert('删除失败');
                //     window.location.href="{:U('Admin/Carousel/index')}";
                // }
            }
        })
	}
	else{
		alert("请选择您要删除的内容!");
		return false;
	}
}

</script>
</body>
</html>